package com.zoffy.catdiarybackend.controller;

import com.zoffy.catdiarybackend.common.BaseResponse;
import com.zoffy.catdiarybackend.common.IdRequest;
import com.zoffy.catdiarybackend.common.ResultUtils;
import com.zoffy.catdiarybackend.model.vo.FriendVo;
import com.zoffy.catdiarybackend.service.FriendshipService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/friendship")
public class FriendShipController {
    @Resource
    private FriendshipService friendshipService;
    @PostMapping("/add")
    public BaseResponse<Boolean> addFriend(HttpServletRequest request,@RequestBody IdRequest idRequest){
        boolean res = friendshipService.addFriend(request, idRequest);
        return ResultUtils.success(res);

    }
    @PostMapping("/delete")
    public BaseResponse<Boolean> deleteFriend(HttpServletRequest request,@RequestBody IdRequest idRequest){
        boolean res=friendshipService.deleteFriend(request,idRequest);
        return ResultUtils.success(res);
    }
    @GetMapping("/")
    public BaseResponse<List<FriendVo>> selectFriend(HttpServletRequest request){
        List<FriendVo> res=friendshipService.selectFriend(request);
        return ResultUtils.success(res);
    }
    @GetMapping("/friend/addRequest")
    public BaseResponse<List<FriendVo>> selectFriendAddRequest(HttpServletRequest request){
        List<FriendVo> friendVos = friendshipService.selectFriendAddRequest(request);
        return ResultUtils.success(friendVos);
    }
    @GetMapping("/friend/addRequest/mine")
    public BaseResponse<List<FriendVo>> selectMyFriendAddRequest(HttpServletRequest request){
        List<FriendVo> friendVos = friendshipService.selectMyFriendAddRequest(request);
        return ResultUtils.success(friendVos);
    }
    @GetMapping("/friend/agree")
    public BaseResponse<Boolean> agreeFriendAddRequest(HttpServletRequest request,long userId){
        boolean res = friendshipService.agreeFriendAddRequest(request, userId);
        return ResultUtils.success(res);
    }
    @GetMapping("/friend/disagree")
    public BaseResponse<Boolean> disagreeFriendAddRequest(HttpServletRequest request,long userId){
        boolean res = friendshipService.disagreeFriendAddRequest(request, userId);
        return ResultUtils.success(res);
    }
}
